package marsdonne.demo4gorm

import grails.gorm.multitenancy.Tenant
import grails.gorm.multitenancy.Tenants
import marsdonne.demo4gorm.domains.Book
import org.grails.datastore.mapping.mongo.MongoDatastore
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner

@Ignore
@RunWith(SpringRunner)
@SpringBootTest(classes = Demo4gormApplication.class)
class MultiTenancyTests {
    @Test
    @Tenant(value = { "mongoTenant2" }, datastore = MongoDatastore)
    void testBookWithTenant_2() {
        new Book(name: "123", author: "mars").save(flush: true)

        assert Tenants.currentId(MongoDatastore) == "mongoTenant2"

        assert Book.count == 1
    }
}
